﻿using System.Collections.ObjectModel;
using System.ComponentModel;

namespace MetroCalendar.ViewModels
{
    public class AlarmViewModel : INotifyPropertyChanged
    {
        #region internal data
        private ObservableCollection<string> _repeatTypeList;
        private ObservableCollection<string> _ringToneList;

        private RepeatType _repeatType;
        private RingTone _ringTone;
        #endregion

        #region peoperty
        public ObservableCollection<string> RepeatTypeList
        {
            get
            {
                return _repeatTypeList;
            }
        }

        public ObservableCollection<string> RingToneList
        {
            get
            {
                return _ringToneList;
            }
        }

        public RepeatType RepeatType
        {
            get
            {
                return _repeatType;
            }
            set
            {
                RepeatType newRepeatType = (RepeatType)value;
                if (_repeatType != newRepeatType)
                {
                    _repeatType = newRepeatType;
                    RaisePropertyChanged("RepeatType");
                }
            }
        }

        public RingTone RingTone
        {
            get
            {
                return _ringTone;
            }
            set
            {
                RingTone newRingTone = (RingTone)value;
                if (_ringTone != newRingTone)
                {
                    _ringTone = newRingTone;
                    RaisePropertyChanged("RingTone");
                }
            }
        }
        #endregion

        #region constructor
        public AlarmViewModel()
        {
            _repeatTypeList = new ObservableCollection<string>();
            _repeatTypeList.Add("Not repeated");
            _repeatTypeList.Add("Daily");
            _repeatTypeList.Add("Weekly");
            _repeatTypeList.Add("Fortnightly");
            _repeatTypeList.Add("Monthly");
            _repeatTypeList.Add("Yearly");

            _ringToneList = new ObservableCollection<string>();
            _ringToneList.Add("bell 1");
            _ringToneList.Add("bell 2");
            _ringToneList.Add("bell 3");

            RepeatType = RepeatType.NotRepeated;
            RingTone = RingTone.Bell2;
        }
        #endregion

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
